home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
StepZkrolly demo ƒ
/
StepZkrolly.p
< prev
next >
Wrap
Text File
|
1995-01-17
|
3KB
|
126 lines
{This is a quick hack on Zkrolly to tweak it into a step-scrolling demo instead.}
{A case that I find much more realistic is to use a fairly large offscreen, perhaps the size of a 17" screen,}
{and use the full screen on smaller screens, with step-scrolls as necessary. I might make something like it}
{later, but this at least shows the principle.}
program StepZkrolly;
uses
{$ifc UNDEFINED THINK_PASCAL}
Types, QuickDraw, Fonts, Windows, Dialogs, OSUtils, Memory, {}
{$endc}
SAT, sXprite, sZprite;
var
ignoresp, zp: SpritePtr;
zWind: WindowPtr;
r: Rect;
const
scrollsizeH = 250;
scrollsizeV = 200;
var
nowOff: Point;
procedure Zteppy;
var
where: Point;
srcRect: Rect;
{max och min borde vara inline!}
function max (a, b: integer): integer;
begin
if a > b then
max := a
else
max := b;
end;
function min (a, b: integer): integer;
begin
if a < b then
min := a
else
min := b;
end;
begin
where := zp^.position;
where.h := where.h - BSR(scrollsizeH, 2);
where.v := where.v - BSR(scrollsizeV, 2);
if where.h < 0 then
where.h := 0;
if where.v < 0 then
where.v := 0;
if where.h + scrollsizeH > gSAT.offSizeH then
where.h := gSAT.offSizeH - scrollsizeH;
if where.v + scrollsizeV > gSAT.offSizeV then
where.v := gSAT.offSizeV - scrollsizeV;
if (abs(where.h - nowOff.h) > scrollsizeH div 3) or (abs(where.v - nowOff.v) > scrollsizeV div 3) then
repeat
begin
{nowOff := where;}
if nowOff.h > where.h then
nowOff.h := max(nowOff.h - 5, where.h);
if nowOff.h < where.h then
nowOff.h := min(nowOff.h + 5, where.h);
if nowOff.v > where.v then
nowOff.v := max(nowOff.v - 5, where.v);
if nowOff.v < where.v then
nowOff.v := min(nowOff.v + 5, where.v);
SATSetPortScreen;
SetOrigin(nowOff.h, nowOff.v);
srcRect := gSAT.wind.port^.portRect;
CopyBits(gSAT.offScreen.port^.portBits, gSAT.wind.port^.portBits, srcRect, srcRect, srcCopy, nil);
{SATCopyBitsToScreen(gSAT.offScreen, srcRect, srcRect, false);}
end
until longint(nowOff) = longint(where);
end;
procedure SetupZwind;
var
zr: Rect;
wrld: SysEnvRec;
begin
{Since SAT hasn't been initialized, we can't use gSAT.colorFlag but have to check environs ourselves.}
if noErr <> SysEnvirons(1, wrld) then
; {ignore errors}
SetRect(zr, 20, 30, 20 + scrollSizeH, 30 + scrollSizeV);
if wrld.hasColorQD then
Zwind := NewCWindow(nil, zr, '', false, plainDBox, WindowPtr(-1), false, 0)
else
Zwind := NewWindow(nil, zr, '', false, plainDBox, WindowPtr(-1), false, 0);
end;
begin
{In case this isn't Think Pascal we have to make the standard inits ourselves.}
{$IFC UNDEFINED THINK_PASCAL}
SATInitToolbox;
{$ENDC}
SetupZwind;
SetRect(r, 0, 0, 510, 340);
SATCustomInit(128, 129, r, zwind, nil, false, false, false, true, false);
InitXprite;
InitZprite;
ShowWindow(gSAT.wind.port);
SelectWindow(gSAT.wind.port);
zp := SATNewSprite(0, 90, 70, @SetupZprite);
ignoresp := SATNewSprite(0, 120, 100, @SetupXprite);
ignoresp := SATNewSprite(0, 200, 160, @SetupXprite);
SATSoundOff;
SATRedraw;
SATSetPortScreen;
repeat
SATRun(false);
Zteppy;
until Button;
{WARNING! It seems like we mess up the current device somewhere. Probably a bug in SAT}
{(where the device setting isn't perfect yet). Let's set port and device to something nice and safe!}
SATSetPortScreen;
SATSoundShutup;
end.